<template>
    <div>
        <el-table :data="songData" stripe highlight-current-row class="table">
            <el-table-column prop="userID" label="id" width="130">
            </el-table-column>
            <el-table-column prop="account" label="账号" width="130">
            </el-table-column>
            <el-table-column prop="password" label="密码" width="100">
            </el-table-column>
            <el-table-column prop="userName" label="昵称" width="100">
            </el-table-column>
            <el-table-column prop="gender" label="性别" width="100">
            </el-table-column>
            <el-table-column prop="age" label="年龄" width="100">
            </el-table-column>
            <el-table-column prop="phone" label="电话" width="130">
            </el-table-column>
            <el-table-column prop="headImg" label="头像路径" width="200">
            </el-table-column>
            <el-table-column label="操作" width="130">
                <template slot-scope="scope">
                    <el-button size="mini" @click="favorites(scope.$index, scope.row)">
                        删除
                    </el-button>
                    <router-link class="me" :to="{ path: '/information2', query: { id:scope.row.userID } }">
                        <button>编辑</button>
                    </router-link>
                </template>
            </el-table-column>
        </el-table>

    </div>
</template>

<script>
export default {
    data() {
        return {
            songData: null,
            
        }
    },
    methods: {
        favorites: function (index, row) {
            this.axios({
                url: "/api/users/usersDelete",
                params: {
                    userID: row.userID
                }
            }).then(res => {
                if (res.data.code == 200) {
                    this.$message({
                        message: '删除成功',
                        type: 'success'
                    });
                } else {
                    this.$message({
                        message: '删除失败',
                        type: 'warning'
                    });
                }
            }).catch(err => {
                console.log("歌曲收藏错误", err);
            })
        },
    },
    created: function () {
        this.axios({
            url: "/api/users/usersAll"
        }).then(res => {
            console.log(res.data);
            this.songData = res.data.data.results
        }).catch(err => {
            console.log("admin用户请求失败");
        })
    }
}
</script>

<style></style>